package com.itheima.tlias.exception;

import com.itheima.tlias.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(BizException.class)
    public Result runtimeException(BizException e) {
        log.error(e.getMessage(), e);
        return Result.error(e.getExc());
    }

    @ExceptionHandler(Exception.class)
    public Result exception(Exception e) {
        log.error(e.getMessage(), e);
        return Result.error("服务异常，请联系管理员");
    }
}
